﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Text;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Web;
using IronOne.SalesOne.DataObjects.QuotationReportDSTableAdapters;


namespace IronOne.SalesOne.SalesOneWeb.SalesQuotations
{
    public partial class ViewReport81 : System.Web.UI.Page
    {
        string quoNum = string.Empty;

        protected void Page_Load(object sender, EventArgs e)
        {
            quoNum = Page.Request.Params["QuotationNum"].ToString();

            ReportDocument UnitReport = new ReportDocument();
            string reportPath = Server.MapPath("RptUnit81.rpt");
            UnitReport.Load(reportPath);


            UnitLinkedQuoTableAdapter UnAdp = new UnitLinkedQuoTableAdapter();
            DataTable dt = UnAdp.GetDataByUnitLinkDatails(quoNum);

            UnitReport.SetDataSource((DataTable)dt);
            CrystalReportViewer1.ReportSource = UnitReport;


            MemoryStream oStream; // using System.IO
            oStream = (MemoryStream)
            UnitReport.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            //CrystalDecisions.Shared.DiskFileDestinationOptions DiskOpts = new CrystalDecisions.Shared.DiskFileDestinationOptions();

            Response.Clear();
            Response.Buffer = true;
            Response.ContentType = "application/pdf";
            Response.BinaryWrite(oStream.ToArray());
            Response.End();


        }
    }
}
